﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Fashion.Models;

namespace Fashion.ViewModels
{
    public class UserSearchViewModel
    {
        private FashionEntities1 FashionDB = new FashionEntities1();

        public string username { get; set; }
        public DateTime registerDate { get; set; }

        public List<User> Users { get; set; }
        public int totalUsers { get; set; }
        
        public List<User> SearchByUsername(string username, int start, int offset)
        {
            var userModel = from users in FashionDB.Users
                            where users.Username.Contains(username)
                            orderby users.RegisterDate descending
                            select users;
            this.totalUsers = userModel.Count();
            var userList = userModel.Skip(start).Take(offset);
            return new List<User>(userList);
        }
    }
}